var express = require('express');
var test_library_router = express.Router();
// let Articles = require("../mongodb/mongodb").Articles //引入数据库模型
let {
  tests,//试题库
} = require("../mongodb/mongodb")
//实时资讯
test_library_router.get('/tests', function(req, res, next) {
  let DB = tests;
  let _id = req.query._id;
  console.log("查询id为："+_id+"试题信息")
  if(_id!=null){
    DB.find({_id:_id}).exec(function(err,docs){
      if(err){
        console.log(err)
        console.log("错误");
        res.send({
          status:300,
          msg:'暂时没有新的数据'
        })
      }else{
        res.send(docs)
      }
    }) 
  }else{
    res.send("where is your id？")
  }
});


module.exports = test_library_router;